return ret;
}
+static char *
+create_name_internal (char *buf,
+ size_t maxlen,
+ const Babl *source,
+ const Babl *destination,
+ int is_reference)
+{
+ return snprintf (buf, maxlen, "%s %p %p",
+ is_reference ? "ref "
+ : "",
+ source, destination);
+}
+
static char *
create_name (const Babl *source,
const Babl *destination,
int is_reference)
{
- static char buf[1024];
+ int size = 0;
+ char *buf = NULL;
+
+ size = create_name_internal (buf, size, source, destination, is_reference);
+
+ if (size < 0)
+ return NULL;
+
+ size++; /* For '\0' */
+ buf = malloc (size);
+ if (buf == NULL)
+ return NULL;
+
+ size = create_name_internal (buf, size, source, destination, is_reference);
+
+ if (size < 0)
+ {
+ free (buf);
+ return NULL;
+ }
- /* fish names are intentionally kept short */
- snprintf (buf, 1024, "%s %p %p",
- is_reference ? "ref "
- : "",
- source, destination);
return buf;
}
Babl *babl = NULL;
char *name = create_name (source, destination, 1);
+ babl_assert (name);
+
babl = babl_db_exist_by_name (babl_fish_db (), name);
if (babl)
{
/* There is an instance already registered by the required name,
* returning the preexistent one instead.
*/
+ free (name);
return babl;
}
* name, inserting newly created class into database.
*/
babl_db_insert (babl_fish_db (), babl);
+ free (name);
return babl;
}